﻿var columns =
            [
                 { display: 'TypeId', name: 'TypeId', type: 'text', hide: 1 },
                 { display: 'Id', name: 'Id', type: 'text', hide: 1 },
                { display: '类别名称', name: 'TypeName', width: 120 },
                { display: '模块名称', name: 'TypeModuleName', width: 120 },
                { display: '选项名称', name: 'RefeName', width: 120 },
                 { display: '选项编码', name: 'RefeCode', width: 100 },
                  { display: '选项状态', name: 'State', width: 80 }
             ];

//init controls
var manager;
$(document).ready(function () {
    initligerGrid();
});
function initligerGrid() {
    manager = null;
    manager = $("#refeGrid").ligerGrid({
        columns: columns,
        title: '字码表',
        showTitle: true,
        width: '100%',
        enabledSort: true,
        height: '99%',
        rownumbers: true,
        checkbox: false,
        toolbar: { items: [
                            { text: '增加', click: addRole, icon: 'add' },
                            { line: true },
                            { text: '删除', click: deleteRole, img: '../Content/images/delete.gif' }
                           ]
        },
        groupColumnName: 'TypeName', groupColumnDisplay: '',
        url: "../Refe/GetAllRefeTypes?rand="+Math.random()
    });
}
//add
function addRole() {
    var row = manager.getSelectedRow();
    if (!row) { $.ligerDialog.success('请选择需要添加的类别行！'); return; }
    $.ligerDialog.open({ url: '../Refe/AddRefe?refeTypeId=' + row["TypeId"].toString(), height: getDialogHeight(), width: getDialogWidth(), isResize: true, isHidden: false
    });
}
//delete
function deleteRole() {
    var row = manager.getSelectedRow();
    if (!row) { $.ligerDialog.success('请选择需要删除行！'); return; }
    $.ligerDialog.confirm('确定要删除吗？', function (yes) {
        if (yes) {
            $.get("../Refe/EditRefe?refeId=" + row["Id"].toString(), {}, function (data) {
                if (data != undefined && data == "ok") {
                    initligerGrid();
                }
            });
        }
    });
}
